<!DOCTYPE html>
<html>
{include file="public/header" /}
<body>
<style>


    .s{
        clear:both;
        margin-top: 10px
    }
</style>

<div class="layui-fluid" id="app">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">

                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

                        <ul class="layui-tab-title">
                            <li class="" onclick="go('index')">案例</li>
                            <li class="layui-this" onclick="go('add_cases')">新增案例</li>
                        </ul>

                        <div class="layui-tab-content" style="padding-left: 0px;padding-right: 0px">
                            <div class="layui-tab-item layui-show" style="padding-top: 15px">
                                <form class="layui-form " action="">

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">名称</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="cases_name" value="" class="layui-input" lay-verify="required" placeholder="请输入">
                                        </div>
                                    </div>




                                    <div class="layui-form-item" >

                                        <div class="layui-inline">
                                            <label class="layui-form-label">户型</label>
                                            <div class="layui-input-inline" style="width: 300px;">
                                                <input type="text" name="house_type" value="" class="layui-input" lay-verify="required" placeholder="请输入">
                                            </div>

                                        </div>

                                        <div class="layui-inline">
                                            <label class="layui-form-label">面积</label>
                                            <div class="layui-input-inline" style="width: 300px;">
                                                <input type="text" name="area" value="" class="layui-input" lay-verify="required" placeholder="请输入">
                                            </div>
                                            <div class="layui-form-mid">㎡</div>
                                        </div>

                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label">缩略图片</label>

                                        <div class="layui-input-block " style="width: auto;">

                                            <div class="layui-upload-drag" id="pic1" style="padding: 2px">
                                                <img class="layui-upload-img"
                                                     style="width: 120px;height: 120px; object-fit: cover;"
                                                     src="/res/img/thumb.png">
                                                <input type="hidden" name="small_img" value=""
                                                       lay-verify="required">
                                            </div>
                                        </div>
                                    </div>




                                    <div class="layui-form-item">
                                        <label class="layui-form-label">内容</label>
                                        <div class="layui-input-block">
                                            <a class="layui-btn" onclick="hre()">点击添加图片</a>
                                        </div>
                                    </div>

                                    <div class="layui-form-item">
                                        <div class="layui-input-inline" style="width: 300px !important;">
                                            <label class="layui-form-label">收藏人数</label>
                                            <div class="layui-input-block">
                                                <input type="text" name="collect_number" value="1" class="layui-input" lay-verify="required">
                                            </div>
                                        </div>

                                    </div>

                                    <div class="layui-form-item">
                                        <label class="layui-form-label"></label>
                                        <div class="layui-input-block">
                                            <input type="checkbox" name="status" value="1" lay-skin="primary"  title="发布" checked>
                                            <input type="checkbox" name="remen" value="1" lay-skin="primary" title="设为热门">
                                        </div>
                                    </div>



                                    <!--<div class="layui-form-item">-->
                                        <!--<label class="layui-form-label">区域</label>-->
                                        <!--<div class="layui-input-inline" style="width: 200px !important;">-->
                                            <!--<select name="sheng" lay-verify="required">-->
                                                <!--&lt;!&ndash;<option value="">请选择省</option>&ndash;&gt;-->
                                                <!--<option value="河南省" selected="">河南省</option>-->
                                            <!--</select>-->
                                        <!--</div>-->
                                        <!--<div class="layui-input-inline" style="width: 200px !important;">-->
                                            <!--<select name="shi" lay-verify="required">-->
                                                <!--&lt;!&ndash;<option value="">请选择市</option>&ndash;&gt;-->
                                                <!--<option value="周口市">周口市</option>-->
                                            <!--</select>-->
                                        <!--</div>-->
                                        <!--<div class="layui-input-inline" style="width: 200px !important;">-->
                                            <!--<select name="xian" lay-verify="required">-->
                                                <!--&lt;!&ndash;<option value="">请选择县/区</option>&ndash;&gt;-->
                                                <!--<option value="川汇区">川汇区</option>-->
                                                <!--<option value="东新区">东新区</option>-->

                                            <!--</select>-->
                                        <!--</div>-->
                                    <!--</div>-->

                                    <!--<div class="layui-form-item">-->
                                        <!--<label class="layui-form-label">详细地址</label>-->
                                        <!--<div class="layui-input-block">-->
                                            <!--<input type="text" name="address" value="" class="layui-input" lay-verify="required" placeholder="请输入">-->
                                        <!--</div>-->
                                    <!--</div>-->

                                    <div class="layui-form-item form-footer form-footer2">
                                        <div class="layui-input-block">
                                            <button class="layui-btn" lay-submit lay-filter="cases">确认提交</button>
                                            <button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>




<script>

    var app = new Vue({
        el: '#app',
        data: {
            check: [],
            curr: 1,//当前页
            limit: 10,//当前页

        },
    });
    var sel=[];
    var content=[];

    function hre() {
        // var id=$(that).attr('data_id');
//        location.href="{:url('detail')}?id="+id;
        layer.open({
            type: 2,
            title: '案例详情',
            shadeClose: true,
            shade: 0.01,
            area: ['80%', '80%'],
            content: "{:url('add_cases_detail')}" //iframe的url

        })
    }

    layui.use(['form', 'upload','laydate'], function () {
        var $ = layui.$
            , layer = layui.layer
            , form = layui.form;
        var upload = layui.upload;
        var laydate = layui.laydate;


        //网站设置
        //监听submit提交
        form.on('submit(cases)', function (obj) {
            console.log(content);

            obj.field['content']=content;


            $.post("{:url('add_cases')}", obj.field,function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, {icon: 1});
                    $('#pic1 img').attr('src', '/res/img/thumb.png');
                    $('.layui-form')[0].reset();

                    return false;
                } else {
                    layer.msg(res.msg, {icon: 2}, function () {

                    })
                    return false;
                }

            });
            return false;
        });

        //拖拽上传
        upload.render({
            elem: '#pic1'
            , url: '/tool/qiniu/upload'
            , before: function () {
                layer.load(2);
            }
            , done: function (res) {
                layer.closeAll();
                console.log(res)
                $('#pic1 img').attr('src', res.data.url);//完整url
                $('#pic1 input').val(res.data.pic);//存入数据库中的部分url
            }
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#time' //指定元素
        });
    });
</script>
<!--<script type="text/javascript" src="/static/js/jquery-1.11.3.min.js"></script>-->
